﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BiocityFilmquizAdmin.Src.DatabaseAccess;

namespace BiocityFilmquizAdmin
{
    public partial class Texts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void Page_PreRender(object sender, System.EventArgs e)
        {
            renderLoggedInBoxes();
        }

        private void renderLoggedInBoxes()
        {
            if (Session["loggedIn"] != null && (bool)Session["loggedIn"])
            {
                loggedInDiv.Visible = true;
                notLoggedInDiv.Visible = false;

                doIfLoggedIn();
            }
            else
            {
                loggedInDiv.Visible = false;
                notLoggedInDiv.Visible = true;
            }
        }

        private void doIfLoggedIn()
        {
            loggedInText.Text = AdminHelper.getInstance().getProperty("loggedInMessage");
            notLoggedInText.Text = AdminHelper.getInstance().getProperty("notLoggedInMessage");
            aboutText.Text = AdminHelper.getInstance().getProperty("aboutMessage");
            createUserText.Text = AdminHelper.getInstance().getProperty("registerMessage");
            allAnsweredText.Text = AdminHelper.getInstance().getProperty("allSolvedMessage");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            AdminHelper.getInstance().setProperty("loggedInMessage", loggedInText.Text);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            AdminHelper.getInstance().setProperty("notLoggedInMessage", notLoggedInText.Text);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            AdminHelper.getInstance().setProperty("aboutMessage", aboutText.Text);
        }

        protected void createUserButton_Click(object sender, EventArgs e)
        {
            AdminHelper.getInstance().setProperty("registerMessage", createUserText.Text);
        }

        protected void allAnsweredButton_Click(object sender, EventArgs e)
        {
            AdminHelper.getInstance().setProperty("allSolvedMessage", allAnsweredText.Text);
        }
    }
}